package com.j283_5.wisdom_park.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.mapper.RoomMapper;
import com.j283_5.wisdom_park.mapper.TenementMapper;
import com.j283_5.wisdom_park.pojo.Room;
import com.j283_5.wisdom_park.service.RoomService;
import com.j283_5.wisdom_park.vo.asset_management.TenISVo;
import com.j283_5.wisdom_park.vo.contract_management.InsertRoomVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 房间管理表 服务实现类
 * </p>
 *
 * @author laoda
 * @since 2022-04-28
 */
@Service
public class RoomServiceImpl implements RoomService {

    @Resource
    private RoomMapper roomMapper;
    @Resource
    private TenementMapper tenementMapper;
    @Override
    public ResultData insertRoom(InsertRoomVo insertRoomVo) {
        Room room=new Room();
        room.setRoomNo(insertRoomVo.getRoomNo());
        room.setRoomArea(insertRoomVo.getRoomArea());
        room.setTenId(insertRoomVo.getTenId());
        room.setRoomTennum(insertRoomVo.getRoomTennum());
        room.setRoomSituation(insertRoomVo.getRoomSituation());
        room.setRoomMoney(insertRoomVo.getRoomMoney());

        int insert = roomMapper.insert(room);
        if (insert>0){
            return ResultData.ok().message("插入成功");
        }else {
            return ResultData.error().message("插入失败");
        }
    }

    @Override
    public ResultData insertRoomInterface(Integer ten_Id) {
        List<TenISVo> tenId = tenementMapper.findTenId(ten_Id);
        return ResultData.ok().data(tenId);
    }

}
